package com.atguigu.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
@ComponentScan(basePackages = "com.atguigu")
@EnableWebMvc //相当于给 handelerAdapter 配置了json转换器 <mvc:annotation-driven/>
public class JspConfig implements WebMvcConfigurer {
    // 配置jsp解析器
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        //相当于<mvc:view-resolvers prefix="" suffix=".jsp"/>
        //给容器中添加jsp解析器 的位置在哪个目录下
        //前缀/WEB-INF/views 后缀.jsp
        registry.jsp("/WEB-INF/views/", ".jsp");
    }

    //开启静态资源处理 <mvc:default-servlet-handler/>
    //dispatcherServlet -> handlerMapping 没有对应的处理器 -> 找静态资源
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
